

#include "stdafx.h"

#include "CAdvButtonClass.h"



IMPLEMENT_DYNCREATE(CAdvButtonClass, CBitmapButton)

BEGIN_MESSAGE_MAP(CAdvButtonClass, CBitmapButton)
    ON_WM_MOUSEMOVE()
    ON_WM_MOUSELEAVE()
END_MESSAGE_MAP()


CAdvButtonClass::CAdvButtonClass()
{
    b_changeMouse = FALSE;
    m_HandCursor = LoadCursor(NULL,IDC_HAND);
}

CAdvButtonClass::~CAdvButtonClass()
{

}

void CAdvButtonClass::OnMouseMove(UINT ui, CPoint pt) 
{
    TRACKMOUSEEVENT trt;
    trt.cbSize = sizeof(TRACKMOUSEEVENT);
    trt.dwFlags = TME_LEAVE;
    trt.hwndTrack = m_hWnd;
    trt.dwHoverTime = 500;
    TrackMouseEvent(&trt);
    if (b_changeMouse == FALSE)
    {
        b_changeMouse = TRUE;
        //m_OldCursor = SetCursor(m_HandCursor);
        SetClassLong(m_hWnd,    // window handle 
            GCL_HCURSOR,      // change cursor 
            (LONG) m_HandCursor);   
    }

    CBitmapButton::OnMouseMove(ui,pt);
}

void CAdvButtonClass::OnMouseLeave()
{
    if (b_changeMouse)
    {
        b_changeMouse = FALSE;
   /*     SetCursor(m_OldCursor);*/
        SetClassLong(m_hWnd,    // window handle 
            GCL_HCURSOR,      // change cursor 
            (LONG) m_OldCursor);   
    }
    CBitmapButton::OnMouseLeave();
}